package d;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2024-04-28
 * Time: 9:09
 */
public class TcpDictServer extends TcpEchoServer{
    Map<String,String> map = new HashMap<>();
    public TcpDictServer(int port) throws IOException {
        super(port);
        map.put("hello","你好");
        map.put("dog","小狗");
        map.put("cat","小猫");
    }

    @Override
    public String process(String request) {
        return  map.getOrDefault(request,"该词汇没有查到!")+"\n";
    }

    public static void main(String[] args) throws IOException {
        TcpDictServer tcpDictServer = new TcpDictServer(9090);
        tcpDictServer.start();
    }
}
